home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 February
/
Macworld (1998-02).dmg
/
Inside Macworld
/
Alphamania 2 & Effector Sets
/
AlphaMania 2
/
Set FX.dir
/
00081_Script_Slider Bar
< prev
next >
Wrap
Text File
|
1997-12-19
|
4KB
|
127 lines
property pThumbSprite, pFillSprite, pArrowsSprite, pTextSprite, pTextField, pCurVal, pExtraChar, pActive, pCallBackObj, pRefcon
property pRange, pMin, pMax, pSliderLeft, pSliderWidth
on new me, propList
set pFillSprite = getAProp(propList,#fillSprite)
set pThumbSprite = getAProp(propList,#thumbSprite)
set pArrowsSprite = getAProp(propList,#arrowsSprite)
set pTextSprite = getAProp(propList,#textSprite)
set pTextField = getAProp(propList,#textField)
set pMin = getAProp(propList,#min)
set pMax = getAProp(propList,#max)
set pCurVal = getAProp(propList, #cur)
set pSliderLeft = getAProp(propList,#left)
set pSliderWidth = getAProp(propList,#width)
set pExtraChar = getAProp(propList,#suffix)
set pActive = getAProp(propList,#active)
set pCallBackObj = getAProp(propList,#callback)
set pRefCon = getAProp(propList,#ref)
set pRange = pMax - pMin
setVal(me,pCurVal)
setEnabled(me,pActive)
return(me)
end
on wait me, waitTime
put the ticks into t
repeat while the ticks < t+waitTime
end repeat
end
on Arrows me
if not pActive then exit
put the locH of the clickLoc into h1
put the locH of sprite the clickOn into h2
if h1 < h2 then
put "left" into side
put -1 into d
else
put "right" into side
put 1 into d
end if
set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
set newVal = max(min(pCurVal+d,pMax),pMin)
setVal(me,newVal)
if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, newVal)
updateStage
wait(me,5)
repeat while the stillDown
if rollover(pArrowsSprite) then
set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
set pCurVal = max(min(pCurVal+d,pMax),pMin)
else
set the member of sprite pArrowsSprite = member "horizArrows"
end if
setVal(me,pCurVal)
if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, newVal)
wait(me,5)
end repeat
set the member of sprite pArrowsSprite = member "horizArrows"
if objectP(pCallBackObj) then EndChange(pCallBackObj)
end
on Drag me
if not pActive then exit
repeat while the stillDown
put min(max(the mouseH,pSliderLeft),pSliderLeft+pSliderWidth) into h
set the locH of sprite pThumbSprite = h
setFill(me)
updateStage
set loc = the locH of sprite pThumbSprite - pSliderLeft
set pCurVal = ((pRange*loc)/(pSliderWidth))+pMin
TextOut(me)
if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, pCurVal)
end repeat
if objectP(pCallBackObj) then EndChange(pCallBackObj)
end
on setFill me
puppetSprite pFillSprite, TRUE
put the rect of sprite pFillSprite into fillRect
set the right of fillRect = the locH of sprite pThumbSprite
set the left of fillRect = pSliderLeft
set the rect of sprite pFillSprite = fillRect
end
on CalcVal me, numerator, denom, otherDenom
set val = (otherDenom * numerator) / denom
return(val)
end
on TextOut me
if voidP(pCurVal) then put " " into field pTextField
else put string(integer(pCurVal))&pExtraChar into field pTextField
end
on SetVal me, newVal
puppetSprite pThumbSprite, TRUE
set pCurVal = newVal
if voidP(newVal) then put pRange/2 into newVal
TextOut(me)
set loc = CalcVal(me, newVal-pMin, pRange, pSliderWidth)
set the locH of sprite pThumbSprite = pSliderLeft + loc
setFill(me)
--updateStage
end
on SetEnabled me, enabled
set pActive = enabled
enableInterfaceElement(pFillSprite,enabled)
enableInterfaceElement(pThumbSprite,enabled)
enableInterfaceElement(pArrowsSprite,enabled)
enableInterfaceElement(pTextSprite,enabled)
end
on Release me
-- release all puppets, constraints, etc.
puppetSprite pFillSprite, FALSE
puppetSprite pThumbSprite, FALSE
end